package pro.shushi.pamirs.hr.core.init;

import org.springframework.stereotype.Component;
import pro.shushi.pamirs.boot.base.enmu.ActionTargetEnum;
import pro.shushi.pamirs.boot.common.api.command.AppLifecycleCommand;
import pro.shushi.pamirs.boot.common.extend.MetaDataEditor;
import pro.shushi.pamirs.core.common.InitializationUtil;
import pro.shushi.pamirs.hr.api.HrSimpleModule;
import pro.shushi.pamirs.hr.api.model.eam.BsMtool;
import pro.shushi.pamirs.hr.api.model.eam.BsMtoolMd;
import pro.shushi.pamirs.hr.api.model.org.Employee;
import pro.shushi.pamirs.hr.api.tmodel.EmployeeBatchReq;
import pro.shushi.pamirs.meta.api.dto.meta.Meta;
import pro.shushi.pamirs.meta.enmu.ActionContextTypeEnum;
import pro.shushi.pamirs.meta.enmu.ViewTypeEnum;

import java.util.Map;

@Component
public class HrSimpleModuleMetaDataEditor implements MetaDataEditor {

    @Override
    public void edit(AppLifecycleCommand command, Map<String, Meta> metaMap) {
        InitializationUtil util = InitializationUtil.get(metaMap, HrSimpleModule.MODULE_MODULE,
                HrSimpleModule.MODULE_NAME);
        if(util==null){
            return;
        }

        //初始化自定义前端行为
        viewActionInit(util);
    }
    private void viewActionInit(InitializationUtil util){
        util.createViewAction("batch_Update_Employee_Label","批量打标", Employee.MODEL_MODEL, InitializationUtil.getOptions(ViewTypeEnum.TABLE),
                EmployeeBatchReq.MODEL_MODEL, ViewTypeEnum.FORM, ActionContextTypeEnum.SINGLE_AND_BATCH, ActionTargetEnum.DIALOG,"formView",null);

        // 工装信息维护 生成行内复制按钮
        util.createViewAction("BsMtool_Copy","复制", BsMtool.MODEL_MODEL, InitializationUtil.getOptions(ViewTypeEnum.TABLE),
                BsMtool.MODEL_MODEL, ViewTypeEnum.FORM, ActionContextTypeEnum.SINGLE, ActionTargetEnum.ROUTER,null,null)
                // setLoad指定页面加载时调用后端的方法名
                .setLoad("copy");
                //.setTitle(); 可以设置浏览器的标题

        // 工装型号信息维护 生成行内复制按钮
        util.createViewAction("BsMtoolMd_Copy","复制", BsMtoolMd.MODEL_MODEL, InitializationUtil.getOptions(ViewTypeEnum.TABLE),
                        BsMtoolMd.MODEL_MODEL, ViewTypeEnum.FORM, ActionContextTypeEnum.SINGLE, ActionTargetEnum.ROUTER,null,null)
                // setLoad指定页面加载时调用后端的方法名
                .setLoad("copy");
    }
}